#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

typedef short int bool;
#define true    1
#define false   0

#define N 8

char chessboard[N][N] = {{'.'}};

int C = 0;
int n = 0, k = 0;
int path[N] = {0};
int plen = 0;

void showcb()
{
    int i = 0, j = 0;

    for(i = 0; i < n; i++)
    {
        for(j = 0; j < n; j++)
        {
            printf("%c ", chessboard[i][j]);
        }
        printf("\n");
    }
}

bool canplace(int level, int k)
{
    int i = 0;

    for(i = 0; i < level; i++)
    {
        if(path[i] == -1)
        {
            continue;
        }
        if(path[i] == k)
        {
            return false;
        }
    }
    return true;
}

void showpath()
{
    int i = 0;

    for(i = 0; i < n; i++)
    {
        printf("%d ", path[i]);
    }
    printf("=======\n");
}

void fn(int level)
{
    int i = 0;
//
    if((n - level < k) ||(level >= n && k != 0) )
    {
        return;
    }

    if(k == 0)
    {
        C++;
        //showpath();
        return;
    }

    path[level] = -1;
    fn(level+1);

    for(i = 0; i < n; i++)
    {
        if(chessboard[level][i] == '.')
        {
            continue;
        }
        if(canplace(level, i) == true)
        {
            path[level] = i;
            k--;
            fn(level+1);
            k++;
        }
    }
}

void process()
{
    //showcb();
    C = 0;
    memset(path, -1, sizeof(path[0])*N);
    fn(0);

    printf("%d\n", C);
}

int main()
{
    //freopen("bin\\debug\\in.txt", "r", stdin);
    int i = 0, j = 0;
    char line[N+1];

    while(true)
    {
        scanf("%d%d", &n, &k);
        if(n == -1 || k == -1)
        {
            break;
        }
        for(i = 0; i < n; i++)
        {
            scanf("%s", line);
            for(j = 0; j < n; j++)
            {
                chessboard[i][j] = line[j];
            }
        }
        process();
    }

    return 0;
}
